#ifndef ZCL_SALESBOX_DATA_H
#define ZCL_SALESBOX_DATA_H

#include "zcl.h"
#include "zcl_SalesBox.h"

// -------------------------- operat ------------------------
#define OPREAD          ACCESS_CONTROL_READ
#define OPWRITE         ACCESS_CONTROL_WRITE
#define OPREPORT        ACCESS_REPORTABLE

// -------------------------  commands -------------------------
#define BASIC_CMD_S_RX \
  { ZCL_CLUSTER_ID_GEN_BASIC, 0, COMMAND_BASIC_RESET_FACT_DEFAULT, CMD_DIR_SERVER_RECEIVED }

#define IDENTIFY_CMD_S_RX \
  { ZCL_CLUSTER_ID_GEN_IDENTIFY, 0, COMMAND_IDENTIFY, CMD_DIR_SERVER_RECEIVED },\
  { ZCL_CLUSTER_ID_GEN_IDENTIFY, 0, COMMAND_IDENTIFY_QUERY, CMD_DIR_SERVER_RECEIVED }

#define IDENTIFY_CMD_S_TX \
  { ZCL_CLUSTER_ID_GEN_IDENTIFY, 0, COMMAND_IDENTIFY_QUERY_RSP, CMD_DIR_SERVER_GENERATED }

#define ONOFF_CMD_S_RX \
  { ZCL_CLUSTER_ID_GEN_ON_OFF, 0, COMMAND_OFF, CMD_DIR_SERVER_RECEIVED },\
  { ZCL_CLUSTER_ID_GEN_ON_OFF, 0, COMMAND_ON, CMD_DIR_SERVER_RECEIVED },\
  { ZCL_CLUSTER_ID_GEN_ON_OFF, 0, COMMAND_TOGGLE, CMD_DIR_SERVER_RECEIVED }
  
#define LEVEL_CMD_S_RX \
  { ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, 0, COMMAND_LEVEL_MOVE_TO_LEVEL, CMD_DIR_SERVER_RECEIVED },\
  { ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, 0, COMMAND_LEVEL_MOVE, CMD_DIR_SERVER_RECEIVED },\
  { ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, 0, COMMAND_LEVEL_STEP, CMD_DIR_SERVER_RECEIVED },\
  { ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, 0, COMMAND_LEVEL_STOP, CMD_DIR_SERVER_RECEIVED },\
  { ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, 0, COMMAND_LEVEL_MOVE_TO_LEVEL_WITH_ON_OFF, CMD_DIR_SERVER_RECEIVED },\
  { ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, 0, COMMAND_LEVEL_MOVE_WITH_ON_OFF, CMD_DIR_SERVER_RECEIVED },\
  { ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, 0, COMMAND_LEVEL_STEP_WITH_ON_OFF, CMD_DIR_SERVER_RECEIVED },\
  { ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, 0, COMMAND_LEVEL_STOP_WITH_ON_OFF, CMD_DIR_SERVER_RECEIVED }

#define SBOX_CMD_S_RX \
  { MFG_CLUSTER_ID_SBOX, MFG_SBOX_MANUCODE, COMMAND_SBOX_OPEN_BOX, CMD_DIR_SERVER_RECEIVED },\
  { MFG_CLUSTER_ID_SBOX, MFG_SBOX_MANUCODE, COMMAND_SBOX_QUERY_BOX, CMD_DIR_SERVER_RECEIVED },\
  { MFG_CLUSTER_ID_SBOX, MFG_SBOX_MANUCODE, COMMAND_SBOX_QUERY_KEY, CMD_DIR_SERVER_RECEIVED }

#define SBOX_CMD_S_TX \
  { MFG_CLUSTER_ID_SBOX, MFG_SBOX_MANUCODE, COMMAND_SBOX_OPEN_BOX_RSP, CMD_DIR_SERVER_GENERATED },\
  { MFG_CLUSTER_ID_SBOX, MFG_SBOX_MANUCODE, COMMAND_SBOX_QUERY_BOX_RSP, CMD_DIR_SERVER_GENERATED },\
  { MFG_CLUSTER_ID_SBOX, MFG_SBOX_MANUCODE, COMMAND_SBOX_QUERY_KEY_RSP, CMD_DIR_SERVER_GENERATED }

//---------------------- Attributes ---------------------------
#define GEN_BASIC_ATTRS(name)  \
  { ZCL_CLUSTER_ID_GEN_BASIC, 0,{ ATTRID_BASIC_ZCL_VERSION, ZCL_DATATYPE_UINT8, OPREAD, (void *)&name##_ZCLVersion } }, /* ZCL version */\
  { ZCL_CLUSTER_ID_GEN_BASIC, 0,{ ATTRID_BASIC_APPL_VERSION, ZCL_DATATYPE_UINT8, OPREAD, (void *)&name##_APPLVersion } }, /* APP version */\
  { ZCL_CLUSTER_ID_GEN_BASIC, 0,{ ATTRID_BASIC_STACK_VERSION, ZCL_DATATYPE_UINT8, OPREAD, (void *)&name##_StackVersion } }, /* Stack version */\
  { ZCL_CLUSTER_ID_GEN_BASIC, 0,{ ATTRID_BASIC_HW_VERSION, ZCL_DATATYPE_UINT8, OPREAD, (void *)&name##_HWRevision } }, /* Hw verison */\
  { ZCL_CLUSTER_ID_GEN_BASIC, 0,{ ATTRID_BASIC_MANUFACTURER_NAME, ZCL_DATATYPE_CHAR_STR, OPREAD, (void *)name##_ManufacturerName } }, /* manufacturer name*/\
  { ZCL_CLUSTER_ID_GEN_BASIC, 0,{ ATTRID_BASIC_MODEL_ID, ZCL_DATATYPE_CHAR_STR, OPREAD, (void *)name##_ModelId } }, /* model id */\
  { ZCL_CLUSTER_ID_GEN_BASIC, 0,{ ATTRID_BASIC_DATE_CODE, ZCL_DATATYPE_CHAR_STR, OPREAD, (void *)name##_DateCode } }, /* data code */\
  { ZCL_CLUSTER_ID_GEN_BASIC, 0,{ ATTRID_BASIC_POWER_SOURCE, ZCL_DATATYPE_ENUM8, OPREAD, (void *)&name##_PowerSource } }, /* power source */\
  { ZCL_CLUSTER_ID_GEN_BASIC, 0,{ ATTRID_BASIC_LOCATION_DESC, ZCL_DATATYPE_CHAR_STR, (OPREAD|OPWRITE), (void *)name##_LocationDescription } }, /* Location Description */\
  { ZCL_CLUSTER_ID_GEN_BASIC, 0,{ ATTRID_BASIC_PHYSICAL_ENV, ZCL_DATATYPE_ENUM8, (OPREAD|OPWRITE), (void *)&name##_PhysicalEnvironment } }, /* Physical Environment */\
  { ZCL_CLUSTER_ID_GEN_BASIC, 0,{ ATTRID_BASIC_DEVICE_ENABLED, ZCL_DATATYPE_BOOLEAN, (OPREAD|OPWRITE), (void *)&name##_DeviceEnable } }, /* Device Enable */\
  { ZCL_CLUSTER_ID_GEN_BASIC, 0,{ ATTRID_CLUSTER_REVISION, ZCL_DATATYPE_UINT16, OPREAD, (void *)&zcl_clusterRevision_all } }

#define GEN_IDENTIFY_ATTRS(name) \
  { ZCL_CLUSTER_ID_GEN_IDENTIFY, 0,{ ATTRID_IDENTIFY_TIME, ZCL_DATATYPE_UINT16, (OPREAD|OPWRITE), (void *)&name##_IdentifyTime } },/* Identify Time */\
  { ZCL_CLUSTER_ID_GEN_IDENTIFY, 0,{ ATTRID_CLUSTER_REVISION, ZCL_DATATYPE_UINT16, OPREAD, (void *)&zcl_clusterRevision_all } }

#define GEN_ONOFF_ATTRS(name) \
  { ZCL_CLUSTER_ID_GEN_ON_OFF, 0,{ ATTRID_ON_OFF, ZCL_DATATYPE_BOOLEAN, (OPREAD|OPREPORT), (void *)&name##_OnOff } },/* OnOff */\
  { ZCL_CLUSTER_ID_GEN_ON_OFF, 0,{ ATTRID_CLUSTER_REVISION, ZCL_DATATYPE_UINT16, OPREAD, (void *)&zcl_clusterRevision_all } }
  
#define GEN_LEVEL_ATTRS(name) \
  { ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, 0,{ ATTRID_LEVEL_CURRENT_LEVEL, ZCL_DATATYPE_UINT8, OPREAD|OPREPORT,(void *)&name##_LevelCurrentLevel} },/* current level */\
  { ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, 0,{ ATTRID_LEVEL_REMAINING_TIME, ZCL_DATATYPE_UINT16, OPREAD, (void *)&name##_LevelRemainingTime} },/* Level Remaining Time */\
  { ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, 0,{ ATTRID_LEVEL_ON_OFF_TRANSITION_TIME, ZCL_DATATYPE_UINT16, OPREAD|OPWRITE, (void *)&name##_LevelOnOffTransitionTime } },/* Level On Off Transition Time */\
  { ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, 0,{ ATTRID_LEVEL_ON_LEVEL, ZCL_DATATYPE_UINT8, OPREAD|OPWRITE, (void *)&name##_LevelOnLevel } },/* Level On Level */\
  { ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, 0,{ ATTRID_LEVEL_ON_TRANSITION_TIME, ZCL_DATATYPE_UINT16, OPREAD|OPWRITE, (void *)&name##_LevelOnTransitionTime } },/* Level On Transition Time */\
  { ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, 0,{ ATTRID_LEVEL_OFF_TRANSITION_TIME, ZCL_DATATYPE_UINT16, OPREAD|OPWRITE, (void *)&name##_LevelOffTransitionTime } },/* Level Off Transition Time */\
  { ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, 0,{ ATTRID_LEVEL_DEFAULT_MOVE_RATE,ZCL_DATATYPE_UINT16, OPREAD|OPWRITE, (void *)&name##_LevelDefaultMoveRate} },/* Level Default Move Rate */\
  { ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, 0,{ ATTRID_CLUSTER_REVISION, ZCL_DATATYPE_UINT16, OPREAD, (void *)&zcl_clusterRevision_all } }

#define MFG_SBOX_ATTRS(name) \
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_OPENED_BOX, ZCL_DATATYPE_UINT8, OPREAD, (void *)&name##_OpenedBox } },/* Opened Box */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_TOTAL_BOX, ZCL_DATATYPE_UINT8, OPREAD, (void *)&name##_TotalBox } },/* Total Box */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_LAST_BOX, ZCL_DATATYPE_UINT8, OPREAD, (void *)&name##_LastBox } },/* Last Box */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_BOX_STATUS, ZCL_DATATYPE_UINT8, OPREAD|OPREPORT, (void *)&name##_BoxStatus } },/* Box Status */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_SN0, ZCL_DATATYPE_UINT32, OPREAD|OPWRITE, NULL } },/* Box SN 0 */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_SN1, ZCL_DATATYPE_UINT32, OPREAD|OPWRITE, NULL } },/* Box SN 1 */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_SN2, ZCL_DATATYPE_UINT32, OPREAD|OPWRITE, NULL } },/* Box SN 2 */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_SN3, ZCL_DATATYPE_UINT32, OPREAD|OPWRITE, NULL } },/* Box SN 3 */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_SN4, ZCL_DATATYPE_UINT32, OPREAD|OPWRITE, NULL } },/* Box SN 4 */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_SN5, ZCL_DATATYPE_UINT32, OPREAD|OPWRITE, NULL } },/* Box SN 5 */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_SN6, ZCL_DATATYPE_UINT32, OPREAD|OPWRITE, NULL } },/* Box SN 6 */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_SN7, ZCL_DATATYPE_UINT32, OPREAD|OPWRITE, NULL } },/* Box SN 7 */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_SN8, ZCL_DATATYPE_UINT32, OPREAD|OPWRITE, NULL } },/* Box SN 8 */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_SN9, ZCL_DATATYPE_UINT32, OPREAD|OPWRITE, NULL } },/* Box SN 9 */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_SN10, ZCL_DATATYPE_UINT32, OPREAD|OPWRITE, NULL } },/* Box SN 10 */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_SN11, ZCL_DATATYPE_UINT32, OPREAD|OPWRITE, NULL } },/* Box SN 11 */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_SN12, ZCL_DATATYPE_UINT32, OPREAD|OPWRITE, NULL } },/* Box SN 12 */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_SN13, ZCL_DATATYPE_UINT32, OPREAD|OPWRITE, NULL } },/* Box SN 13 */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_SN14, ZCL_DATATYPE_UINT32, OPREAD|OPWRITE, NULL } },/* Box SN 14 */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_SBOX_SN15, ZCL_DATATYPE_UINT32, OPREAD|OPWRITE, NULL } },/* Box SN 15 */\
  { MFG_CLUSTER_ID_SBOX,  MFG_SBOX_MANUCODE,{ ATTRID_CLUSTER_REVISION, ZCL_DATATYPE_UINT16, OPREAD, (void *)&zcl_clusterRevision_all } }

#endif
